import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ImageManager manager = new ImageManager();
        Scanner scanner = new Scanner(System.in);
        boolean running = true;
        
        System.out.println("=== 图片下载系统 ===");
        
        while (running) {
            System.out.println("\n请选择功能：");
            System.out.println("1. 下载图片");
            System.out.println("2. 查看所有图片");
            System.out.println("3. 搜索图片");
            System.out.println("4. 退出");
            System.out.print("请输入选项：");
            
            String choice = scanner.nextLine();
            
            switch (choice) {
                case "1":
                    System.out.print("请输入图片URL：");
                    String url = scanner.nextLine();
                    manager.downloadImage(url);
                    break;
                case "2":
                    manager.listImages();
                    break;
                case "3":
                    System.out.print("请输入图片名称关键词：");
                    String keyword = scanner.nextLine();
                    manager.searchImage(keyword);
                    break;
                case "4":
                    running = false;
                    System.out.println("系统已退出，感谢使用！");
                    break;
                default:
                    System.out.println("无效的选项，请重新输入！");
            }
        }
        
        scanner.close();
    }
}
